package com.bugstack.domain.strategy.service.rule.chain.impl;

import com.bugstack.domain.strategy.repository.IStrategyRepository;
import com.bugstack.domain.strategy.service.armory.IStrategyDispatch;
import com.bugstack.domain.strategy.service.rule.chain.AbstractLogicChain;
import com.bugstack.domain.strategy.service.rule.chain.ILogicChain;
import com.bugstack.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: czb
 * @Description: 保底策略责任链
 * @DateTime: 2025/3/9 21:38
 **/
@Component("default")
@Slf4j
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    private IStrategyDispatch strategyDispatch;

    @Override
    public DefaultChainFactory.StrategyAwardVO logic(String userId, Long strategyId) {
        Integer awardId = strategyDispatch.getRandomAwardId(strategyId);
        String ruleModel = DefaultChainFactory.LogicModel.RULE_DEFAULT.getCode();
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId,ruleModel , awardId);
        return DefaultChainFactory.StrategyAwardVO.builder().awardId(awardId).logicModel(ruleModel).build();
    }
}
